<template>
  <el-col :span="8" class="item">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <div>
          <i class="el-icon-document" style="margin-right: 5px"></i
          >{{ item.data.typeKey }}
        </div>
        <el-button
          style="float: right; padding: 3px 0; color: red"
          type="text"
          >{{ label }}</el-button
        >
      </div>
      <div class="text">
        <p class="title">{{ item.data.taskDescription }}</p>
        <p>{{ item.data.taskDescription }}</p>
      </div>
      <div class="footer">
        <span>{{ new Date(item.data.notifyTime).toLocaleString() }}</span>
        <el-button size="small" @click="toDetail(item.pendingUrl)"
          >详情</el-button
        >
      </div>
    </el-card>
  </el-col>
</template>

<script>
export default {
  name: "ItemComponent",
  props: {
    item: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      stateArr: [
        {
          value: -1,
          label: "已删除",
        },
        {
          value: 0,
          label: "草稿",
        },
        {
          value: 1,
          label: "审核中",
        },
        {
          value: 2,
          label: "已审核",
        },
        {
          value: 5,
          label: "已作废",
        },
        {
          value: 9,
          label: "共享审核中",
        },
        {
          value: 10,
          label: "已增加",
        },
        {
          value: 20,
          label: "已锁定",
        },
      ],
      label: "",
    };
  },
  mounted() {
    this.test();
  },
  methods: {
    test() {
      this.stateArr.forEach((item) => {
        if (this.item.data.state === item.value) {
          this.label = item.label;
        }
      });
    },
    // 跳转到详情页
    toDetail(url) {
      location.href = url;
    },
  },
};
</script>

<style scoped lang="scss">
.item {
  padding: 20px;

  .box-card {
    box-shadow: 0 0px 0px 0 rgb(0 0 0 / 10%);
  }

  .clearfix {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .text {
    height: 100px;

    p {
      margin: 0;
      padding: 0;
    }

    display: flex;
    flex-direction: column;
    justify-content: space-between;

    .title {
      color: #3264d8;
    }
  }

  .footer {
    margin-top: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
}
</style>
